package com.lc.afbx.conn;

import android.util.Log;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/5/31.
 */
@HttpInlet(Conn.INLET_API_LOGIN_SEL)
public class PostApiLogin extends BaseAsyPost<PostApiLogin.Info> {
    public String username, password;


    public PostApiLogin(AsyCallBack<PostApiLogin.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();

            info.code = jsonObject.optString("code");
            info.message = jsonObject.optString("message");

            JSONObject o = jsonObject.optJSONObject("data");

            Data d = new Data();

            try {

                d.id = o.optString("id");
                d.username = o.optString("username");
                d.paycode = o.optString("paycode");
                d.rec_code = o.optString("rec_code");

            } catch (Exception e) {
                e.printStackTrace();
            }

            info.data = d;
            return info;

        }

        return null;

    }

    public static class Info {

        public String message, code;
        public Data data;

    }

    public static class Data {

//        {
//            "code": 200,
//                "message": "成功",
//                "data": {
//            "id": "79",
//                    "username": "18944610773",
//                    "paycode": "false",
//                    "rec_code": "230123"
//        }
//        }

        public String username, id, paycode, rec_code;
    }

}
